import React from "react";
import '../../../static/css/pc/imagetext.less';
import PropTypes from "prop-types";
//import Summary from '../components/summary';
export default class ImageText extends React.Component{
	constructor(){
		super();
		this.state = {
			imagetextNews:[],
			newsdata:[]
		}
	}
	
	componentDidMount(){
		
		var result=fetch("http://www.wwtliu.com/sxtstu/news/juhenews.php?type="+this.props.type+"&count="+this.props.count,{
			method:'get',
			async:true
		})
		.then(res =>{
			return res.json()
		})
		.then(json =>{
			
//			console.log(json)
			this.setState({
				imagetextNews:json,
				temp1:1
				
			})
		})
		
		var newresult=fetch('http://127.0.0.1:3000/newsdata',{
    		method:'get',
    		async:true
    		
    	}).then(response =>{
    		return response.json();
    	}).then(data => {
//  		console.log(data)
    		this.setState({
    			newsdata:data,
    			temp2:1
    			
    		})
    		
    	})
    	
		
		
	}
	render(){
		var {imagetextNews,newsdata}=this.state;
		return(
			<div className='imagetext'>
				{
					imagetextNews.map((item,index)=>{
						return (
							<div className='imagetextShow' key={item.uniquekey}>
								<div className='title'>
									<p className='category'>{item.category}</p>
									<a href={item.url} className='title_t'>{item.title}</a>
									<p className='date'>{item.date}</p>
								</div>
								<div className='IMGShow'>
									<img src={item.thumbnail_pic_s}  className='IMG'/>
									<div className="summary">
									    <h2>摘要</h2>
									    {
										    newsdata.map((item,index)=>{
											    return(
											        <span key={index}>{item.summary}</span>
											    )
										    })
									    }
									</div>
								</div>
								
							</div>
						)
					})
				}
			</div>
		)
	}
}
ImageText.propTypes = {
	type:PropTypes.string,
	count:PropTypes.number
}